<h1>Видео</h1>

<?php echo link_to('жагсаалт', 'video/index', array('class'=>'title'))?> 
<span class="separator"> | </span>
<?php echo link_to('шинээр нэмэх', 'video/new', array('class'=>'title'))?>
<br clear="all">
<br clear="all">

<form action="<?php echo url_for('video/index')?>" method="GET">
  <b>Хайх үг:</b>&nbsp;
  <input id="keyword" name="keyword" value="<?php echo $sf_request->getParameter('keyword')?>" style="width:400px;"/>
  <input type="submit" value="Submit" style="cursor:pointer;font-weight:bold;" />
</form>

<br clear="all">

<?php foreach ($pager->getResults() as $video): ?>
  <div style="width:190px;height:165px;float:left;margin:3px;border:1px solid #ccc;overflow:hidden;position:relative;">
    <iframe width="185" height="150" src="<?php echo html_entity_decode($video->getEmbed())?>" frameborder="0" allowfullscreen></iframe>
    <b><?php echo myTools::utf8_substr($video, 0, 30)?></b>...
    <a style="position:absolute;bottom:0px;right:18px;" href="<?php echo url_for('video/edit?id='.$video->getId()) ?>"><?php echo image_tag('icons/edit.gif', array())?></a>
    <a style="position:absolute;bottom:0px;right:0px;" onclick="return confirm('Та итгэлтэй байна уу?')" href="<?php echo url_for('video/delete?id='.$video->getId()) ?>"><?php echo image_tag('icons/delete.gif', array())?></a>
  </div>
<?php endforeach; ?>

<?php echo pager($pager, 'video/index')?>


<script type="text/javascript">
function loadObjects()
{
  $.ajax({
      url: "<?php echo url_for('video/loadObjects')?>",
      data: {objectType : $('#objectType').val(), objectId: <?php echo $sf_request->getParameter('objectId') ? $sf_request->getParameter('objectId') : 0?>},
      type: "POST",
      success: function(data){
          $('#container_object_id').html('<select id="objectId" name="objectId" style="width:400px;">' + data + '</select>');
      }
  });
  return false;
}

$(document).ready(function() {
    loadObjects();  
});
</script>